package me.muci.factoryPattern.staticFactoryMethod.factory;

import me.muci.factoryPattern.staticFactoryMethod.*;

/**
 * ClassName: OperationFactort <br/>
 * Description: <br/>
 * date: 2021/8/4 11:38<br/>
 *
 * @author muci<br />
 * @description
 * @since JDK 1.8
 */
public class OperationFactory {
    public static Operation createOperation(String operation){
        Operation oper = null;
        switch (operation){
            case "+":
                oper = new OperationAdd();
                break;

            case "-":
                oper = new OperationSub();
                break;

            case "*":
                oper = new OperationMul();
                break;

            case "/":
                oper = new OperationDiv();
                break;
            default:
                throw new UnsupportedOperationException("不支持该操作");
        }
        return oper;
    }
}
